package de.sabram.upb.specs.eee_tools.contextMenuActions;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;

import de.sabram.upb.specs.eee_tools.Activator;

public class EliHelpCommand implements IViewActionDelegate {

	public EliHelpCommand() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void run(IAction action) {	
		MessageConsole console = new MessageConsole("Eli Output", null);
		console.activate();
		ConsolePlugin.getDefault().getConsoleManager()
				.addConsoles(new IConsole[] { console });
		MessageConsoleStream stream = console.newMessageStream();
		try {
			ProcessBuilder pb = new ProcessBuilder(Activator.getDefault()
					.getPreferenceStore().getString("ELI_PATH").toString()
					+ "/eli", Activator.getDefault().getPreferenceStore()
					.getString("CHOICE"), "?");
			pb.start();

		} catch (IOException e) {
			stream.println("ERROR could not find Eli");
		}

	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
		// TODO Auto-generated method stub

	}

	@Override
	public void init(IViewPart view) {
		// TODO Auto-generated method stub

	}
}
